﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL;

public partial class Repzb_glzhb : System.Web.UI.Page
{
    int isDay = 0;
    public static int unit;
    string strApp = "";
    public static string repName = "";
    static string repType = "";
    public string bmp = "";

    BLL.BLLRep br = new BLLRep();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["repName"].ToString() == "cyd")
        {
            repName = "厂用电报表";
            bmp = "cydzb.bmp";
        }
        else if (Request.QueryString["repName"].ToString() == "zh")
        {
            repName = "综合报表";
            bmp = "zhzb.bmp";
        }
        else if (Request.QueryString["repName"].ToString() == "gl")
        {
            repName = "锅炉报表";
            bmp = "glzb.bmp";
        }
        else if (Request.QueryString["repName"].ToString() == "qj")
        {
            repName = "汽机报表";
            bmp = "qjzb.bmp";
        }
        else if (Request.QueryString["repName"].ToString() == "fz")
        {
            repName = "耗差分值指标日报表";
            bmp = "qjzb.bmp";
        }
        if (Request.QueryString["unit"].ToString() == "1")
            unit = 1;
        else
            unit = 2;

        if (Request.QueryString["repType"].ToString() == "zr")
        {
            repType = "日值";
        }
        else if (Request.QueryString["repType"].ToString() == "zy")
        {
        }
        else if (Request.QueryString["repType"].ToString() == "zn")
        {
        }
        else if (Request.QueryString["repType"].ToString() == "zj")
        {
        }


        if (!IsPostBack)
        {
            DateTime dt = System.DateTime.Now;

            this.Date1.Value = dt.AddDays(-1).ToString("yyyy-MM-dd");

            if (DateTime.Now.Day == Convert.ToDateTime(this.Date1.Value).Day)
                isDay = 0;
            else
                isDay = 1;

            strApp = br.RetTableByVal(repName, this.Date1.Value, unit, repType);

            this.show.InnerHtml = strApp;
        }
    }

    protected void btnChaXun_Click(object sender, EventArgs e)
    {
        DateTime dtInput = Convert.ToDateTime(this.Date1.Value);

        if (DateTime.Now.Day == dtInput.Day)
            isDay = 0;
        else
            isDay = 1;

        strApp = br.RetTableByVal(repName, dtInput.ToShortDateString(), unit, repType);

        this.show.InnerHtml = strApp;
    }

    protected void btnPre_Click(object sender, EventArgs e)
    {
        //Response.Write("Pre");

        DateTime dtInput = Convert.ToDateTime(this.Date1.Value).AddDays(-1);

        this.Date1.Value = Convert.ToDateTime(this.Date1.Value).AddDays(-1).ToString("yyyy-MM-dd");

        if (DateTime.Now.Day == dtInput.Day)
            isDay = 0;
        else
            isDay = 1;

        strApp = br.RetTableByVal(repName, dtInput.ToShortDateString(), unit, repType);

        this.show.InnerHtml = strApp;
    }

    protected void btnNext_Click(object sender, EventArgs e)
    {
        //Response.Write("Next");
        DateTime dtInput = Convert.ToDateTime(this.Date1.Value).AddDays(+1);

        this.Date1.Value = Convert.ToDateTime(this.Date1.Value).AddDays(+1).ToString("yyyy-MM-dd");

        if (DateTime.Now.Day == dtInput.Day)
            isDay = 0;
        else
            isDay = 1;

        strApp = br.RetTableByVal(repName, dtInput.ToShortDateString(), unit, repType);

        this.show.InnerHtml = strApp;
    }
}
